const path = require('path');

module.exports = {
  publicPath:
    process.env.NODE_ENV === 'production' ? './' : '',
  lintOnSave: process.env.NODE_ENV !== 'production',
  productionSourceMap: false,

  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'less',
      patterns: [
        path.resolve(__dirname, 'src/assets/common/less/variable.less')
      ] // 引入全局样式变量
    }
  },
  css: {
    loaderOptions: {
      // 给 sass-loader 传递选项
      sass: {
        // @/ 是 src/ 的别名
        // 所以这里假设你有 `src/variables.scss` 这个文件
        data: `
                    @import "@/global.scss";
                    @import "@/其他.scss";
          `
      }
    }
  },

  chainWebpack: config => {
    config.module
      .rule('css')
      .test(/\.css$/)
      .oneOf('vue')
      .resourceQuery(/\?vue/)
      .use('px2rem')
      .loader('px2rem-loader')
      .options({
        remUnit: 75
      })
  },
  // transpileDependencies: [
  //     'vue-echarts',
  //     'resize-detector'
  // ],
  devServer: {
    open: true,
    host: 'localhost',
    port: 8080,
    https: false,
    proxy: {
      '/pedigree/*': {
        target: 'http://139.196.137.184:5000/',
        changeOrigin: true,
        secure: false,
        pathRewrite: { '^/pedigree/': '/' }
      },
      '/traffic/*': {
        target: 'http://139.196.137.184:5003/',
        changeOrigin: true,
        secure: false,
        pathRewrite: { '^/traffic/': '/' }
      },
      '/search/*': {
        target: 'http://139.196.137.184:5004/',
        changeOrigin: true,
        secure: false,
        pathRewrite: { '^/search/': '/' }
      },
			'/api/*': {
			  target: process.env.VUE_APP_byUrl,
			  changeOrigin: true,
			  secure: false,
			  pathRewrite: { '^/api/': '/api/' }
			}
    }
  },

  // 构建时开启多进程处理 babel 编译
  parallel: require('os').cpus().length > 1,

  // https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa
  pwa: {},

  // 第三方插件配置
  pluginOptions: {}


}